<%
 @task = task
 @user = user
 @project = project
 if(task.done==1); donestr = "done"; else; donestr=''; end
 if(task.star==1); starstr = "on"; else; starstr='off'; end
 nb = task.subtasks_count
-%>
<table class="task edit">
<tr><td><a href="#" onclick="star_it(<%=task.id%>);return false;"><img src="/images/star_<%=starstr%>_2.gif" id="st<%=task.id%>" title="special"></a></td>
<td><%= link_to_remote(image_tag('close.gif', {:style=>'float:right'}), {:url=>{:controller=>'task', :action=>'close', :id=>task.id}, :update=>item_name.to_s+'_'+task.id.to_s}) %></td>
</tr>

<tr><td>Progress:</td><td>
<%= radio_button(:task, :progress, 0, {:onfocus => "mover('d')", :onmouseover => "mover('todo')", :onchange => "change('#{task.id}',event);", :class => donestr}) %>
to do

<%= radio_button(:task, :progress, 1, {:onfocus => "mover('d')", :onmouseover => "mover('begun')", :onchange => "change('#{task.id}',event);", :class => donestr}) %>
begun

<%= radio_button(:task, :progress, 2, {:onfocus => "mover('d')", :onmouseover => "mover('d')", :onchange => "change('#{task.id}',event);", :class => donestr, :id => "d#{task.id}"}) %>
done

<%= radio_button(:task, :progress, 3, {:onfocus => "mover('d')", :onmouseover => "mover('givenup')", :onchange => "change('#{task.id}',event);", :class => donestr, :id => "givenup#{task.id}"}) %>
given up

</td></tr>

<tr><td>Project:</td><td>
<% if task.task == nil %>
<%= my_text_field_with_auto_complete(:project, :name, {:onfocus => "mover('p')",:onmouseover => "mover('p')", :id=>"p#{task.id}"}, :skip_style => true) %>
<%
 else

if task.task.project
  project_name = task.task.project.name
else
  project_name = "no project (same as parent task)"
end
 %>
<%= text_field(:project, :name, {:readonly=>true, :id=>"p#{task.id}", :value=>project_name, :disabled=>true }) %>
<% end %>
</td></tr>
<tr><td>Priority:</td><td><%=text_field(:task, :priority, {:onfocus => "mover('pr')",:onmouseover => "mover('pr',this.value)",:size => 1, :class => donestr, :id => "pr#{task.id}"}) %></td></tr>

<!-- Task -->

<tr><td valign="top">Task:</td><td><%=text_area(:task, :title, {:onkeypress => "handle_key('#{task.id}','#{item_name}',event);", :onfocus => "mover('t')",:onmouseover => "mover('t',this.value)",:cols => 60, :rows => 4, :class => donestr, :id => "t#{task.id}"}) %><br/>
Ctrl-Enter: save, Shift-Enter: save with "next" state, Esc: cancel
</td></tr>

<tr><td>Assigned:</td><td><%=my_text_field_with_auto_complete(:user, :name, {:onfocus => "mover('r')",:onmouseover => "mover('r')", :id=>"r#{task.id}"}, :skip_style => true) %></td></tr>
<tr><td>Deadline:</td><td><%=text_field(:task, :duedate, {:onfocus => "dispcal('#{task.id}',this.value);",:onmouseover => "mover('da')",:size => 10, :class => donestr, :id => "da#{task.id}"}) %>
<%= render(:partial => 'task/deadline', :locals => {:task=>task}) %>
</td></tr>

<tr><td>State:</td><td>
<%=radio_button(:task,:state, 'next', :disabled=>!is_my_task, :id=>"next_#{task.id}")%> next
<%=radio_button(:task,:state, 'waiting', :disabled=>!is_my_task)%> waiting
<%=radio_button(:task,:state, 'maybe', :disabled=>!is_my_task)%> maybe
<%=radio_button(:task,:state, 'ref', :disabled=>!is_my_task)%> ref
<%=radio_button(:task,:state, 'folder', :disabled=>!is_my_task)%> subproject

</td></tr>

<tr bgcolor="#DDDDFF">

<td>Time:</td>
<td>
orig est
<%=text_field(:task, :orig_est,{:size => 2, :class => donestr, :id => "initest#{task.id}"}) %>
curr est
<%=text_field(:task, :cur_est,{:size => 2, :class => donestr, :id => "curest#{task.id}"}) %>
elapsed
<%=text_field(:task, :elapsed,{:size => 2, :class => donestr, :id => "timeused#{task.id}"}) %>

<% if task.remains == nil %>

in hours.<br/>

<% else %>
remains:
<%= task.remains %>
all:
<%= task.subremains %><br/>
<% end %>

<%if nb > 0 %>
This task has <%= nb %> subtasks. The remaining time will take the subtasks time into account.<br/>
You should fill subtasks estimation.
<% end %>
</td>

</tr>

<tr><td></td><td>
<a href="#" onmouseover="mover('s')" onclick="save('<%=task.id%>','<%=item_name%>');return false;"><img id="s<%=task.id%>" src="/images/save.png" border="0"></a>
<a href="#" onmouseover="mover('n')" onclick="notes(<%=task.id%>);return false;"><img id="n<%=task.id%>" src="/images/notes.png" border="0"></a>
<a href="#" onmouseover="mover('de')" onclick="asking_delete('<%=task.id%>','<%=item_name%>');return false;"><img id="de_<%=item_name%>_<%=task.id%>" src="/images/delete.gif" border="0"></a>
<div style="display:inline" id="deadline<%=task.id%>">
</div>
<% if(task.notes_count > 0) -%>
(<%= task.notes_count -%> notes)
<% end -%>
<div id="done_on_<%=task.id%>" class="done_on"><% if task.done_on %>done <%= time_ago_in_words(task.done_on) %> ago<% end %></div>
</td></tr>
<tr><td valign="top">
<%= link_to_function(image_tag('expand.gif'), "$('options_#{task.id}').toggle()") %>
Options
</td><td>
<div id="options_<%=task.id%>" style="display:none">
Created on: <%= task.created_at %> <b><%= time_ago_in_words(task.created_at) %></b><br/>
<%= pluralize(task.tasks.size, 'child') %><br/>
<%= link_to_remote('mark children not done', :url => {:controller=>'task', :action=>'undo_children',:id=>task.id, :item_name=>item_name}, :update=>item_name.to_s+'_'+task.id.to_s, :confirm=>'This will undo all children') %>
</div>

</td></tr>
</table>
<script>$('t<%=task.id%>').focus();</script>

